<?php

use Workerman\Worker;
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/config/common.php';

// 注意：这里与上个例子不同，使用的是websocket协议
$worker = new Worker(WEBSOCKET_URL);

// 启动4个进程对外提供服务
$worker->count = 4;

// 加载处理客户端连接、消息和关闭的处理程序类
$worker->onConnect = '\handle\connect\Index::handle';
$worker->onMessage = '\handle\message\Index::handle';
$worker->onClose = '\handle\close\Index::handle';
$worker->onError = '\handle\error\Index::handle';
$worker->onWorkerStart = '\handle\start\Index::handle';

// 运行worker
Worker::runAll();